package com.example.ruoyivoicecall.util;

import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;
import java.io.File;

/**
 * 系统配置工具类
 */
public class SysConfigUtil {
    private static Properties properties = new Properties();

    static {
        try (InputStream input = SysConfigUtil.class.getClassLoader().getResourceAsStream("application.properties")) {
            if (input != null) {
                properties.load(input);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    /**
     * 获取服务器路径
     */
    public static String getServerPath() {
        return properties.getProperty("voice.server.path", "http://localhost:7627");
    }

    /**
     * 获取服务器文件目录名称
     */
    public static String getServerFileDirName() {
        return properties.getProperty("voice.server.file.dir", "voice_files");
    }

    /**
     * 获取服务器IP
     */
    public static String getServerIP() {
        return properties.getProperty("voice.server.ip", "localhost");
    }

    /**
     * 获取服务器端口
     */
    public static String getServerPort() {
        return properties.getProperty("voice.server.port", "7627");
    }

    /**
     * 获取管理员账号
     */
    public static String getAdminName() {
        return properties.getProperty("voice.admin.name", "1000");
    }

    /**
     * 获取管理员密码
     */
    public static String getAdminPassword() {
        return properties.getProperty("voice.admin.password", "1");
    }

    /**
     * 获取语音单元URL
     */
    public static String getVoiceUnitUrl() {
        return properties.getProperty("voice.unit.url", "http://localhost:7627");
    }

    /**
     * 获取语音单元用户名
     */
    public static String getVoiceUnitUserName() {
        return properties.getProperty("voice.unit.username", "1000");
    }

    /**
     * 获取语音单元密码
     */
    public static String getVoiceUnitPassword() {
        return properties.getProperty("voice.unit.password", "1");
    }

    /**
     * 获取文件上传文件夹名称
     */
    public static String getFileUploadFolderName() {
        return properties.getProperty("voice.file.upload.folder", "upload");
    }

    /**
     * 获取本地语音保存路径
     */
    public static String getLocalVoiceSavePath() {
        return properties.getProperty("voice.local.save.path", System.getProperty("user.dir") + File.separator + "voice");
    }

    /**
     * 获取配置值
     */
    public static String getConfigValue(String key, String defaultValue) {
        return properties.getProperty(key, defaultValue);
    }
}